package org.gdpu.Service.Impl;

import org.gdpu.Service.CollegeService;
import org.gdpu.Service.MajorService;
import org.gdpu.base.DaoSupport;
import org.gdpu.model.Campus;
import org.gdpu.model.College;
import org.gdpu.model.Major;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by HEWI2 on 2/17/14.
 */

@Service
@Transactional
public class MajorServiceImpl extends DaoSupport<Major> implements MajorService {

    private CollegeService collegeService;

    @Override
    public List<Major> findByCollege(String college) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("college", collegeService.find(College.class,Integer.valueOf(college)));
        return this.findByFields(Major.class, params);
    }

    @Override
    public List<Major> findByName(String major) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("majorId", Integer.valueOf(major));
        return this.findByFields(Major.class, params);
    }

    @Resource(name = "collegeServiceImpl")
    public void setCollegeService(CollegeService collegeService) {
        this.collegeService = collegeService;
    }
}
